import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
import show from '@dfeidao/atom-web/ui/show';
import fire from '@dfeidao/atom-web/msg/fire';
import render from '@dfeidao/atom-web/render/render';
import p002 from './p002';
import p001 from './p001';
import p003 from './p003';

export default async function a001(fd: IFeidaoAiBrowserComponent) {
	// todo
	const res  = await nodejs<{d1:Array<{dyremindtime:string,work_order_type:string,project_no:string,project_name:string}>}>("test-web/zj-000004/s001","");
	const ret1 = Array();
	for (let i = 0; i < res.d1.length; i++) {
		ret1[i] = res.d1[i].work_order_type;
	}
	const retq = Array();
	for (let i = 0; i < res.d1.length; i++) {
		retq[i] = res.d1[i].project_no;
	

	}
	const qqq = Array.from(new Set(retq));
	const retqq = Array();
	for (let i = 0; i < res.d1.length; i++) {
		
		retqq[i] = res.d1[i].project_name;

	}
	const sss = Array.from(new Set(retqq));
	const b = Array();
	for (let index = 0; index <retq.length; index++) {
		b[index] = {s:qqq[index],a:sss[index]};
	}
	const q = Array.from(new Set(retq));

	const s = Array.from(new Set(ret1));
	const ret2 = Array();
	for (let i = 0; i < res.d1.length; i++) {
		ret2[i] = res.d1[i].dyremindtime;
	}
	const s1 = Array.from(new Set(ret2));
	render(fd,s1,p002,'p002','inner');
	render(fd,b,p003,'p003','inner');



	const add =fd.data.node.querySelector<HTMLDivElement>('[data-id="add"]');
	set_node_cls(add,'display-n',false);
	show(fd.data.node);
	fire('zj-000001','a001');
	fire('zj-000003','a001');
	fire('zj-000002','a002');


}
